package org.coc.iot.service;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.coc.iot.entity.SysRole;
import org.coc.iot.mapper.SysRoleActionMapper;
import org.coc.iot.mapper.SysRoleMapper;
import org.coc.iot.mapper.SysRoleMenuMapper;
import org.coc.iot.mapper.SysRoleUserMapper;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @Description:实现类
 * @author 
 * @version 1.0
 * @created 
 */
@Service
public class SysRoleService extends BaseService<SysRole, SysRoleMapper> implements InitializingBean {

	@Autowired
	private SysRoleMapper sysRoleMapper;

	@Autowired
	private SysRoleUserMapper sysRoleUserMapper;

	@Autowired
	private SysRoleMenuMapper sysRoleMenuMapper;

	@Autowired
	private SysRoleActionMapper sysRoleActionMapper;
	
	public void afterPropertiesSet() throws Exception {
		this.setBaseMapper(sysRoleMapper);
	}

	/**
	 *
	 * @param id
	 */
	public void deleteRole(Long id) {
		Map<String, Object> param = new HashMap<String,Object>();
		param.put("roleId", id);
		sysRoleUserMapper.deleteSysRoleUserByRoleId(param);
		sysRoleMenuMapper.deleteSysRoleMenuByRoleId(param);
		sysRoleActionMapper.deleteSysRoleActionByRoleId(param);
		param = new HashMap<>();
		param.put("id", id);
		sysRoleMapper.delete(param);
	}

}
